package test02.b;

/**
 * @Author lzp
 * @Date 2024-03-20
 */
public class test {
    public static void main(String[] args) throws InterruptedException {
        SumThread st1 = new SumThread(1,100);
        SumThread st2 = new SumThread(101,900);
        SumThread st3 = new SumThread(901,1000);

        //启动线程，分段统计
        st1.start();
        st2.start();
        st3.start();

        //等待st1/2/3这几个子线程完成
        st1.join();
        st2.join();
        st3.join();

        //合并各线程的和
        int r = st1.getSum() + st2.getSum() + st3.getSum();

        System.out.println(r);

    }
}
